package com.cloudsigns.factorymanager2.engineering.presenter;

import com.cloudsigns.factorymanager2.engineering.IView.ITeamReceivedEngineeringOrderListVIew;
import com.cloudsigns.factorymanager2.engineering.bean.OrderParentBean;
import com.cloudsigns.factorymanager2.engineering.model.ITeamReceivedEngineeringOrderListModel;
import com.cloudsigns.factorymanager2.engineering.model.TeamReceivedEngineeringOrderListModel;

import java.util.List;

/**
 * Created by tony on 2018/4/6.
 */

public class TeamReceivedEngineeringOrderListPresenter {
    private ITeamReceivedEngineeringOrderListVIew view;
    private ITeamReceivedEngineeringOrderListModel model;
    private android.os.Handler mHandler = new android.os.Handler();


    public TeamReceivedEngineeringOrderListPresenter(ITeamReceivedEngineeringOrderListVIew view) {
        this.view = view;
        this.model = new TeamReceivedEngineeringOrderListModel();
    }

    public void getTeamReceivedEngineeringOrderList() {
        view.showLoading();

        model.getTeamReceivedEngineeringOrderList(new TeamReceivedEngineeringOrderListModel.OnTeamReceivedEngineeringOrderListListener() {
            @Override
            public void getTeamReceivedEngineeringOrderListSuceesed(final List<OrderParentBean> orderParentBeanList) {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.getTeamReceivedEngineeringOrderListSuceesed(orderParentBeanList);
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void getTeamReceivedEngineeringOrderListFailed(final String desc) {
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.getTeamReceivedEngineeringOrderListFailed(desc);
                        view.hideLoading();
                    }
                });
            }


        });
    }
}
